#ifndef CGAMEAPP_H
#define CGAMEAPP_H

#include <iostream>
#include <list>
#include "Texture.h"
#include "CEntity.h"
#include "CPlayer.h"
#include "CEnemy.h"
#include "CWave.h"
//#include "CSpaceInvadersWave.h"
//#include "CrsfWave.h"
#include "Audio.h"
#include "CPolygon.h"
#include "CSpecialItem.h"
using namespace std;

#define MAX_ENEMIES 2


class CGameApp
{
public:
	CGameApp();
	~CGameApp();

	void Update();
	void Render();

	void LoadTextures();
	void LoadTexture( char* fileName , Texture& tex );

	void InitializeGame();
	void UpdateTime();
	void CheckCollision();
	void SortLevelBlocks( CEntity* target );
	void CreateNewWave();

	void AddItem( CSpecialItem* itemToAdd );
	void DetachItem( CSpecialItem* itemToDetach ); // for removing an item without deleting it
	void RemoveItem( CSpecialItem* itemToRemove );
	void RemoveAllItems();
	void UpdateItems();
	void AttachItemToHost( CSpecialItem * item , CEntity * host );
	void LoadLevel();

//private:

	CPlayer** Player;		//pointer to the player object pointers
	int NumPlayers;
	CEnemy** Enemy;		//pointer to an array of enemy pointers
	CWave* EnemyWave;
	int NumEnemies;			//number of enemies in the Enemy array
	int NumBlocks;
	CEntity** Block;		//pointer to a block/wall object array 
	CPolygon* Polygons; //polygon array for angled walls
	int NumPolygons;
	//CPolygon PolyBlock;

	//CSpecialItem PowerUp;
	list< CSpecialItem* > PowerUps;

	Texture  PlayerTexture;
	Texture  PlayerTextureOne, PlayerTextureOneMirror;
	Texture  PlayerTextureTwo, PlayerTextureTwoMirror;
	Texture  PlayerTextureThree, PlayerTextureThreeMirror;
	Texture  PlayerTextureFour, PlayerTextureFourMirror;
	Texture  PlayerTextureFive, PlayerTextureFiveMirror;

	Texture	 PlayerMirrorTexture;
	Texture  EnemyTexture;
	Texture	 EnemyDamageTexture;
	Texture	 BulletTexture;
	Texture  BulletBreakTexture;
	Texture* FireAnimationTexture;
	Texture	 WallTexture;

	Texture  TopLeftTexture,		TopLeftBrokenTexture;
	Texture	 TopCenterTexture,		TopCenterBrokenTexture;
	Texture  TopRightTexture,		TopRightBrokenTexture;

	Texture  CenterLeftTexture,		CenterLeftBrokenTexture;
	Texture  CenterCenterTexture,	CenterCenterBrokenTexture;
	Texture  CenterRightTexture,	CenterRightBrokenTexture;

	Texture  BottomLeftTexture,		BottomLeftBrokenTexture;
	Texture  BottomCenterTexture,	BottomCenterBrokenTexture;
	Texture  BottomRightTexture,	BottomRightBrokenTexture;

	Texture  LeftHorizontalTexture,   LeftHorizontalBrokenTexture;
	Texture  CenterHorizontalTexture, CenterHorizontalBrokenTexture;
	Texture	 RightHorizontalTexture,  RightHorizontalBrokenTexture;

	Texture  TopVerticalTexture,    TopVerticalBrokenTexture;
	Texture  CenterVerticalTexture, CenterVerticalBrokenTexture;
	Texture	 BottomVerticalTexture, BottomVerticalBrokenTexture;

	Texture  SingleTexture,			SingleBrokenTexture;
	Texture  CheckpointTextureTexture;

	Texture  GhostTexture;

	Texture* ExplosionTexture;

	Texture* EnemyExplosionTexture; 
	//int EnemyExplosionTextureSize;

	Texture	 BackgroundTexture;
	Texture  WelcomeTexture;
	Texture  EndGameTexture;

	



	Audio* audio;	

	bool* KeyState;
	bool* ArrowState;
	float LastTime;			//time as of last frame
	float CurrentTime;		//time as of current frame
	float DeltaTime;		//time difference between frames
	float GameSpeed;		//speed of the overall game
	bool  FriendlyFire;
	float WorldEdge;

};


#endif